home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilsys / rss14gmd.lha / RSys_1.4gmd / C / GfxCtrl.c < prev    next >
C/C++ Source or Header  |  1996-05-04  |  3KB  |  120 lines

  1. /*
  2.    ***************************************************************************
  3.    *
  4.    * Datei:
  5.    *      RSysGfxCtrl.c
  6.    *
  7.    * Inhalt:
  8.    *
  9.    *      --- Globale Routinen ---
  10.    *
  11.    *    UWORD ComputeX ( UWORD value );
  12.    *    UWORD ComputeY ( UWORD value );
  13.    *    void ComputeFont ( SCREEN *wndscr , UWORD width , UWORD height );
  14.    *    WORD compute ( UWORD offset , UWORD xy , int measure );
  15.    *
  16.    *      --- Lokale  Routinen ---
  17.    *
  18.    *
  19.    * Bemerkungen:
  20.    *      Graphics-Routinen für die Unterstützung fontsensitiver
  21.    *      Benutzeroberflächen.
  22.    *
  23.    * Erstellungsdatum:
  24.    *      25-Jun-93     Rolf Böhme
  25.    *
  26.    * Änderungen:
  27.    *      25-Jun-93     Rolf Böhme        Erstellung
  28.    *
  29.    ***************************************************************************
  30.  */
  31.  
  32. #include "RSys.h"
  33. #include "protos.h"
  34.  
  35. /*
  36.    * compute() berechnet die fontsensitiven Abmessungen von
  37.    * Intuition-Objekten
  38.  */
  39. WORD
  40. compute (UWORD offset, UWORD xy, int measure)
  41. {
  42.   return (WORD) (offset + ((xy * (measure * FRAC)) / FULL));    /* GMD */
  43. }
  44.  
  45. /*
  46.    * computeX() berechnet einen Wert bezüglich der
  47.    * Fontbreite
  48.  */
  49. UWORD
  50. ComputeX (UWORD value)
  51. {
  52.   return ((UWORD) (((FontX * value) + 4) / 8));
  53. }
  54.  
  55. /*
  56.    * computeY() berechnet einen Wert bezüglich der
  57.    * Fonthöhe
  58.  */
  59. UWORD
  60. ComputeY (UWORD value)
  61. {
  62.   return ((UWORD) (((FontY * value) + 4) / 8));
  63. }
  64.  
  65.  
  66. /*
  67.    * ComputeFont() berechnet die korrekte Breite und Höhe eines
  68.    * Fonts. Passen Höhe und Breite eines Abschnittes, verknüpft
  69.    * mit den Fontdaten nicht auf den angegebenen Screen, wird der
  70.    * System-Standard-Font topaz in der Größe 8 verwendet
  71.  */
  72. void
  73. ComputeFont (SCREEN * wndscr, UWORD width, UWORD height)
  74. {
  75.  
  76.   DPOS;
  77.  
  78.   if (Flags.sysfont)
  79.     {
  80.       Font = &Topaz80;
  81.       FontX = 8;
  82.       FontY = 8;
  83.       Font->ta_YSize = 8;
  84.     }
  85.   else
  86.     {
  87.       Forbid ();
  88.       Font = &TAttr;
  89.       Font->ta_Name = (STRPTR) GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
  90.       Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
  91.       FontX = GfxBase->DefaultFont->tf_XSize;
  92.       Permit ();
  93.     }
  94.  
  95.   OffX = wndscr->WBorLeft;
  96.   OffY = wndscr->RastPort.TxHeight + wndscr->WBorTop + 1;
  97.  
  98.   if (width && height)
  99.     {
  100.       if ((ComputeX (width) + OffX + wndscr->WBorRight) > wndscr->Width)
  101.     goto UseTopaz;
  102.       if ((ComputeY (height) + OffY + wndscr->WBorBottom) > wndscr->Height)
  103.     goto UseTopaz;
  104.     }
  105.  
  106.   return;
  107.  
  108. UseTopaz:
  109.   ErrorHandle ((char *) Font->ta_Name, FONT_ERR, SIZE_FAIL, NO_KILL);
  110.  
  111.   Font = &Topaz80;
  112.   FontX = 8;
  113.   FontY = 8;
  114.   Font->ta_YSize = 8;
  115.  
  116.   Flags.sysfont = 1;
  117.  
  118.   return;
  119. }
  120.